#!/usr/bin/env bash
# 重启基于uwsgi运行的python应用服务（通过杀死旧进程-》启动新进程）


# 显示初始信息
echo -e "\033[34m--------------------wsgi process--------------------\033[0m"
ps -ef|grep nb_uwsgi.ini | grep -v grep
sleep 0.5


# 杀死旧进程
echo -e '\n--------------------going to close--------------------'
ps -ef |grep nb_uwsgi.ini | grep -v grep | awk '{print $2}' | xargs kill -9
sleep 0.5


# 启动新的uwsgi服务
echo -e '\n----------check if the kill action is correct----------'
/envs/nb/bin/uwsgi  --ini  nb_uwsgi.ini &  >/dev/null


# 显示成果信息并验证
echo -e '\n\033[42;1m----------------------started...----------------------\033[0m'
sleep 1
ps -ef |grep nb_uwsgi.ini | grep -v grep
